#include<iostream>
#include<map>
#include<vector>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
ll power[100];
void solve()
{
    ll n, kk, k;
    cin >> n >> k;
    vector<ll> a(n + 1), sum(n + 1, 0);
    map<ll, ll> mp;
    for (ll i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum[i] = sum[i - 1] + a[i];
        mp[sum[i] % k]++;
    }
    ll ans = 0;
    mp[0]++;
    for (auto i : mp)
        if (i.second >= 2)
        {
            ans += (i.second - 1) * i.second / 2;
        }
    cout << ans;
}
int main()
{
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}
